import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2024-05-07
 * Time: 20:53
 */
public class Test {
    public static void main(String[] args) {
        HashMap<Integer,String> map = new HashMap<>();
        map.put(1,"a");
        map.put(2,"b");
        map.put(3,"c");
        map.put(4,"d");

        map.forEach(new BiConsumer<Integer, String>() {
            @Override
            public void accept(Integer integer, String s) {
                System.out.println("key: " + integer + " " + "val: " + s);
            }
        });

        map.forEach((integer,s)-> System.out.println("key: " + integer + " " + "val: " + s));
    }

    public static void main1(String[] args) {
        ArrayList<Integer> List = new ArrayList<>();
        List.add(91);
        List.add(2);
        List.add(37);
        List.add(4);
        /*List.forEach(new Consumer<Integer>() {
            @Override
            public void accept(Integer integer) {
                System.out.println(integer);
            }
        });*/

        List.sort(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1.compareTo(o2);
            }
        });

        List.sort((o1,o2) -> o1.compareTo(o2));


        List.forEach(a->System.out.println(a));
    }
}
